function pageInit(){
	getData(getDataUrl, requestParam);
	resData             = resData.data;
	console.log(resData);
	$('#id_lott_shangqi').html(resData.shangqi.period);
	$('#id_lott_lotting').html(resData.lotting.period);
	$('#id_lott_next').val(resData.nextbet.period);
	var now_timestamp   = (Date.parse(new Date()) / 1000) * 1; // js的时间戳会带毫秒
	// 当前期号结束时间减掉当前时间戳为剩下时间
//	running_time = resData.lotting.stoptime - now_timestamp;
	running_time = resData.lotting.stoptime - resData.suportData.nowTime;
	daojishi();
	// 上期开奖
	clearTimeout(clear_kj_ready);
	shangqi_kj_reday(2000, resData.shangqi.code);
}

/**
 * =========================================================================
 * 倒计时计算，返回00:00:00形式倒计时
 * @param second
 */
function daojishi (){
	var hour   = '00';
	var minute = '00';
	var second = '00';
	if (running_time <= 0){
		$('.tag_runningtime').html(hour + ':' + minute + ':' + second);
		// 当前期号结束，获取下批期号信息， 并重新载入数据.
		var content_msg  = resData.shangqi.period + '期已截止<br/>';
			content_msg += '当前期号<font style="color: red;">' + $('#id_lott_next').val() + '</font><br/>';
			content_msg += '投注时请注意期号';
			showMsg('温馨提示', content_msg, '');
			setTimeout("pageInit()", 1000);
		return;
	}
	hour       = parseInt(running_time / (60 * 60));
	minute     = parseInt(running_time / (60));
	second     = parseInt(running_time % (60));
	if(hour == 0){
		hour = '00';
	}else if(hour > 0 && hour < 10){
		hour = '0' + hour;
	}
	if(minute == 0){
		minute = '00';
	}else if(minute > 0 && minute < 10){
		minute = '0' + minute;
	}
	if(second == 0){
		second = '00';
	}else if (second > 0 && second < 10){
		second = '0' + second;
	}
	$('#tag_runningtime').html(hour + ':' + minute + ':' + second);
	running_time--;
	setTimeout("daojishi()", 1000);
}

/**
 * 获取页面数据
 * url：请求路劲
 * param：提交参数
 * reload：是否刷新页面
 */
function getData(url, param={}, reload=''){
	$.ajax({  
		type:'post',    
	    url: url,  
	    data:'data=' + JSON.stringify(param),  
	    cache:false,  
	    dataType:'json',  
	    async:false,
	    success:function(res){  
	    	if(res.msg){
	    		if(res.status == 'success'){
	    			showMsg('温馨提示', res.msg, reload);		    		
		    	}else{
		    		var msg = '网络错误，请刷新页面重试';
		    		if(res.msg){
		    			msg = res.msg;
		    		}
		    		showMsg('温馨提示', msg);
		    	}
	    	}else{
	    		resData = res;
	    	}
	    }  
	})
}
//function showMsg(title, content, reload=''){
//	layer.open({
//        title: title,
//        content: content,
//        className: 'layui-m-tag-msg',
//        btn: ['确定'],
//        yes: function (index){
//			// 继续投注
//        	layer.close(index);
//        	if(reload){
//        		window.location.reload();
//        	}
//        },
//    });
//}

/**
 * 上期开奖前面旋转2秒后展示开奖结果
 * @param seconds
 */
var shangqi_kj       = 1;
var clear_kj_ready   = '';
function shangqi_kj_reday(seconds, code_str){
	if(seconds <= 0){
		shangqi_kaijiang(code_str);
		return;
	}
	if(!$.isEmptyObject(code_str)){
		// 如果上期有开奖，则准备展示上期开奖结果
		seconds = seconds - 50;
	}
	if(shangqi_kj > 11) shangqi_kj = 1;
	$('#id_shangqi_open em').html(shangqi_kj);
	shangqi_kj++;
	clear_kj_ready = setTimeout('shangqi_kj_reday(' + seconds + ', "' + code_str + '")', 50);
}

/**
 * 上期开奖结果，这里主要是js效果以及控制
 */
function shangqi_kaijiang(code_str){
	var kaijiang_code = code_str.split(',');
	for(var i = 0; i < 5; i++){ $('#id_shangqi_open em').eq(i).html(kaijiang_code[i]); }
}

/**
 * 选择主玩法填充从玩法
 * @returns
 */
var type_code   = '';
var follow_code = '';
function fillFollowPlay (obj=''){
	$('#id_current_mainplay').html($('#id_main_play li[class="curr"]').html());
	$('#id_follow_playlist').html('');
	// 置空从玩法
	play_follow = {'follow_index':'', 'base':''};
	$.each(play_main.base.play, function (i, v){
		if($.isEmptyObject(play_follow.base)){
			play_follow.follow_index = i;
			play_follow.base         = play_main.base.play[i];
		}
		// 如果请求来源于切换玩法，则重新设定从玩法内容
		if(i == $(obj).attr('amv')){
			play_follow.follow_index = i;
			play_follow.base = play_main.play[i];
		}
		$('#id_follow_playlist').append('<a class="tag_followplay_item" amv="' + i + '">' + v.name + '</a>');
	})
	$('#id_follow_playlist a').eq(0).addClass('curr');
	user_play   = play_main.main_index + '-' + play_follow.follow_index;
	$('#id_now_play_title').html(play_main.base.play_name + ' ' + play_follow.base.name);
	ready_bet             = {};
	betting[user_play]    = {
		'one'   : new Array(),
		'two'   : new Array(),
		'three' : new Array(),
	};
}

/**
 * 更新玩法操作界面
 * @returns
 */
function fillPlayBody(){
	var nowPlay = resData.codeKeyList[play_main.main_index + '-'][play_main.main_index + '|'][play_follow.follow_index];
	if(!$.isEmptyObject(nowPlay)){
		$('#id_play_tips').html(nowPlay.explain);
		// 动态读取该用户在当前彩种玩法中的实际赔率信息
		$('.tag_pc_bonus').html(nowPlay.odds);
	}else{
		// 选择从玩法，加载从玩法方式内容与说明
		$('.tag_play_explain').html('多重玩法');
	}
	// 填充玩法区域内容
	$('#id_play_body').html('');
	var content  = '';
	// 选项标识的唯一ID
	var item_id  = '';
	if(play_follow.base.item.option == 'import'){
		content += '<div class="textareaNumber">';
		content += '	<textarea class="tag_import_content" placeholder=" 每一注号码之间请使用空格分开，每注之间以回车、逗号或分号进行分隔"></textarea>';
		content += '</div>';
	}else{
		$.each(play_follow.base.item, function (index, value){
			content += '<div class="selectNumber fix">';
			content += '	<div class="title fix">';
			content += '		<em><p>' + value.name + '</p></em> ';
			content += '	</div>';
			content += '	<div class="numberContent">';
			item_id  = '';
			if(value.option == 'baseItem'){
				$.each(resData.playItem.baseItem, function (i, v){
					item_id = 'id_' + index + '_' + v.title;
					v.title = parseInt(v.title);
					if(v.title < 10) {
						v.title = '0' + v.title;
					}
					content += '	<a class="tag_choice_item" amw="' + v.winner_money + '" group="' + index + '" ami="' + v.title + '" id="' + item_id + '"><span>' + v.title + '</span></a>';
				});
			}else{
				$.each(value.option, function (i1, v1){
					item_id = 'id_' + index + '_' + v1.title;
					if(!isNaN(v1.title)){
						v1.title = parseInt(v1.title);
						if(v1.title < 10){
							v1.title = '0' + v1.title;
						}
					}
					content += '	<a class="tag_choice_item" amw="' + v1.winner_money + '" group="' + index + '" ami="' + v1.title + '" id="' + item_id + '"><span>' + v1.title + '</span></a>';
				});
			}
			content += '	</div>';
			content += '</div>';
		});
	}
	if($.inArray(play_main.main_index + '-' + play_follow.follow_index, ['QWX-DDS']) > -1){
		// 给主div增加 quWei 标识
		$('#id_sscMain').addClass('quWei');
	}else{
		$('#id_sscMain').removeClass('quWei');
	}
	$('#id_play_body').html(content);
	ready_bet             = {};
	betting[user_play]    = {
		'one'   : [],
		'two'   : [],
		'three' : [],
	};
}


var ready_bet       = {};   // 预投注项对象
var ready_bet_index = 1;    // 每次确定选号都加入到预投注项中，同彩种同玩法一样
// 手动投注，检查有效的投注号
function check_valid_bet(obj='', func=''){
	// 初始化预投注项对象
	var tmp        = {};
	var item       = {
			'bet': [],
			'check': 'success',
	};
	var index      = 0;
	// 解读预投注信息为ready_bet格式
	ready_bet   = {'bet_name': user_play, 'bet_item': {}, 'bet_unit': 0, 'bet_money_unit': 0, 'bet_zhushu': 0, 'bet_beishu': 0, 'maxwinner': 0, 'period':resData.lotting.period, 'bet_amount':'', 'betting':betting[user_play] };
	var mast_choice_num_controll = 0;
	switch(play_main.main_index + '-' + play_follow.follow_index){
		case 'SM-QS_ZHI_XFS':
			// 三码玩法：前三直选复式
			$.each(betting[user_play].one, function (i1, v1){
				$.each(betting[user_play].two, function (i2, v2){
					$.each(betting[user_play].three, function (i3, v3){
						item.bet         = [];
						item.bet.push(v1);
						item.check       = $.inArray(v2, item.bet) >= 0 ? 'error' : 'success';
						item.bet.push(v2);
						item.check       = ($.inArray(v3, item.bet) >= 0 || item.check == 'error') ? 'error' : 'success';
						item.bet.push(v3);
						// 跳过当前，继续循环
						if(item.check == 'error') return true;
						tmp[index]       = {'bet':item.bet, 'check':item.check};
						index++;
					})
				})
			})
			break;
		case 'SM-QS_ZU_XFS':
			// 三码玩法：前三组选复式
			for(var i = 0; i < betting[user_play].one.length - 2; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z]], 'check':'success'};
						index++;
					}
				}
			}
			break;
		case 'SM-QS_ZU_XDT':
			// 这里检查是两组选项中是否有冲突项
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 2){
				// 胆码最多两个，超过两个则把上次选中的值踢出
				var bet_now = betting[user_play].one.pop();
				var bet_out = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				// 更新选中样式
				$('#id_' + $(obj).attr('group') + '_' + bet_out).removeClass('curr');
			}
			var otherBetArr = '';
			var otherGroup  = 1;
			if($(obj).attr('group') == 1){
				otherBetArr = betting[user_play].two;
				otherGroup  = 2;
			}else{
				otherBetArr = betting[user_play].one;
			}
			
			// 检查当前选择的投注数值是否已经存在点亮的数据中
			if($.inArray($(obj).attr('ami'), otherBetArr) > -1){
				// 删除重复数据
				otherBetArr.splice(($.inArray($(obj).attr('ami'), otherBetArr)), 1);
				// 改变选中样式
				$('#id_' + otherGroup + '_' + $(obj).attr('ami')).removeClass('curr');
			}
			// 三码玩法：前三组选胆拖【胆码最多两个，胆拖可多个，并且胆码胆拖整体不重复数】
			if(parseInt(betting[user_play].one.length + betting[user_play].two.length) < 3){
				// 三个起
				break;
			}
			if(func){
				switch(func){
					case 'da':
					case 'xiao':
					case 'ji':
					case 'ou':
						$.each(betting[user_play].one, function (i, v){
							var checkRep = $.inArray(v, betting[user_play].two);
							if(checkRep > -1){
								// 功能性按键优先，剔除胆组的重复项
								betting[user_play].one.splice(i, 1);
								// 重设被踢出项的样式
								$('#choice_item_' + v + '[group="' + otherGroup + '"]').removeClass('curr');
							}
						})
						break;
					case 'qing':
						break;
					default:
						// 如果请求来自功能性按键， 清空另一个选码项，并改变选择样式
						$('.tag_choice_item[group="' + otherGroup + '"]').removeClass('curr');
						if($(obj).attr('group') == 1){
							betting[user_play].two.length = 0;
						}else{
							betting[user_play].one.length = 0;
						}
						break;
				}
			}else{
				if($(obj).attr('group') == 1){
					betting[user_play].two = otherBetArr;
				}else{
					betting[user_play].one = otherBetArr;
				}
			}
			if(betting[user_play].one.length == 2){
				// 二胆拖一码
				$.each(betting[user_play].two, function (i, v){
					tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].one[1], v], 'check':'success'};
					index++;
				})
			}else{
				// 一胆拖二码
				for(var i1 = 0; i1 < betting[user_play].one.length; i1++){
					for(var i2 = 0; i2 < betting[user_play].two.length; i2++){
						for(var i3 = i2 + 1; i3 < betting[user_play].two.length; i3++){
							tmp[index]    = {'bet':[betting[user_play].one[i1], betting[user_play].two[i2], betting[user_play].two[i3]], 'check':'success'};
							index++;
						}
					}
				}
			}
			break;
		case 'EM-QE_ZHI_XFS':
			// 二码玩法：前二直选复式
			var check = 'success';
			$.each(betting[user_play].one, function (i1, v1){
				$.each(betting[user_play].two, function (i2, v2){
					check = 'success';
					if(v1 == v2) {
						check = 'error';
					}
					tmp[index]    = {'bet':[v1, v2], 'check':check};
					index++;
				})
			})
			break;
		case 'EM-QE_ZU_XFS':
			// 二码玩法：前二组选复式
			for(var i = 0; i < betting[user_play].one.length - 1; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j]], 'check':'success'};
					index++;
				}
			}
			break;
		case 'EM-QE_ZU_XDT':
			// 二码玩法：前二组选胆拖【胆码最多两个，胆拖可多个，并且胆码胆拖整体不重复数】
			if(parseInt(betting[user_play].one.length + betting[user_play].two.length) < 2){
				// 两个起
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				// 胆码最多两个，超过两个则把上次选中的值踢出
				var bet_now = betting[user_play].one.pop();
				var bet_out = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				// 更新选中样式
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			var otherBetArr = '';
			var otherGroup  = 1;
			if($(obj).attr('group') == 1){
				otherBetArr = betting[user_play].two;
				otherGroup  = 2;
			}else{
				otherBetArr = betting[user_play].one;
			}
			if(func){
				// 如果请求来自功能性按键， 清空另一个选码项，并改变选择样式
				$('.tag_choice_item[group="' + otherGroup + '"]').removeClass('curr');
				if($(obj).attr('group') == 1){
					betting[user_play].two.length = 0;
				}else{
					betting[user_play].one.length = 0;
				}
			}else{
				// 检查当前选择的投注数值是否已经存在点亮的数据中
				if($.inArray($(obj).attr('ami'), otherBetArr) > -1){
					// 删除重复数据
					otherBetArr.splice(($.inArray($(obj).attr('ami'), otherBetArr)), 1);
					// 改变选中样式
					$('#choice_item_' + $(obj).attr('ami') + '[group="' + otherGroup + '"]').removeClass('curr');
				}
				if($(obj).attr('group') == 1){
					betting[user_play].two = otherBetArr;
				}else{
					betting[user_play].one = otherBetArr;
				}
			}
			$.each(betting[user_play].one, function (i1, v1){
				$.each(betting[user_play].two, function (i2, v2){
					tmp[index]    = {'bet':[v1, v2], 'check':'success'};
					index++;
				})
			})
			break;
		case 'BDW-QSYMBDW':
			// 不定位：前三一码不定位
			$.each(betting[user_play].one, function (i, v){
				tmp[index]    = {'bet':[v], 'check':'success'};
				index++;
			})
			break;
		case 'DWD-FS':
			// 定位胆：复式
			$.each(betting[user_play].one, function (i1, v1){
				// 第一个位置的投注项
				tmp[index]    = {'bet':[v1, '', ''], 'check':'success'};
				index++;
			})
			$.each(betting[user_play].two, function (i2, v2){
				// 第一个位置的投注项
				tmp[index]    = {'bet':['', v2, ''], 'check':'success'};
				index++;
			})
			$.each(betting[user_play].three, function (i3, v3){
				// 第一个位置的投注项
				tmp[index]    = {'bet':['', '', v3], 'check':'success'};
				index++;
			})
				
			break;
		case 'QWX-DDS':
			// 趣味型：定单双
		case 'QWX-CZW':
			// 趣味型：猜中位
			$.each(betting[user_play].one, function (i1, v1){
				// 第一个位置的投注项
				tmp[index]    = {'bet':[v1], 'check':'success'};
				index++;
			})
			break;
		case 'RXFS-YZY':
			// 任选复式：一中一
			$.each(betting[user_play].one, function (i1, v1){
				// 第一个位置的投注项
				tmp[index]    = {'bet':[v1], 'check':'success'};
				index++;
			})
			nums = 1;
			break;
		case 'RXFS-EZE':
			// 任选复式：二中二
			for(var i = 0; i < betting[user_play].one.length - 1; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j]], 'check':'success'};
					index++;
				}
			}
			break;
		case 'RXFS-SZS':
			// 任选复式：三中三   
			for(var i = 0; i < betting[user_play].one.length - 2; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z]], 'check':'success'};
						index++;
					}
				}
			}
			break;
		case 'RXFS-SI_Z_SI':
			// 任选复式：四中四
			for(var i = 0; i < betting[user_play].one.length - 3; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						for(var x = z+1; x < betting[user_play].one.length; x++){
							tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z], betting[user_play].one[x]], 'check':'success'};
							index++;
						}
					}
				}
			}
			break;
		case 'RXFS-WZW':
			// 任选复式：五中五
			for(var i = 0; i < betting[user_play].one.length - 4; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						for(var x = z+1; x < betting[user_play].one.length; x++){
							for(var c = x+1; c < betting[user_play].one.length; c++){
								tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z], betting[user_play].one[x], betting[user_play].one[c]], 'check':'success'};
								index++;
							}
						}
					}
				}
			}
			break;
		case 'RXFS-LZW':
			// 任选复式：六中五
			for(var i = 0; i < betting[user_play].one.length - 5; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						for(var x = z+1; x < betting[user_play].one.length; x++){
							for(var c = x+1; c < betting[user_play].one.length; c++){
								for(var v = c+1; v < betting[user_play].one.length; v++){
									tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z], betting[user_play].one[x], betting[user_play].one[c], betting[user_play].one[v]], 'check':'success'};
									index++;
								}
							}
						}
					}
				}
			}
			break;
		case 'RXFS-QZW':
			// 任选复式：七中五
			for(var i = 0; i < betting[user_play].one.length - 6; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						for(var x = z+1; x < betting[user_play].one.length; x++){
							for(var c = x+1; c < betting[user_play].one.length; c++){
								for(var v = c+1; v < betting[user_play].one.length; v++){
									for(var b = v+1; b < betting[user_play].one.length; b++){
										tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z], betting[user_play].one[x], betting[user_play].one[c], betting[user_play].one[v], betting[user_play].one[b]], 'check':'success'};
										index++;
									}
								}
							}
						}
					}
				}
			}
			break;
		case 'RXFS-BZW':
			// 任选复式：八中五
			for(var i = 0; i < betting[user_play].one.length - 7; i++){
				for(var j = i+1; j < betting[user_play].one.length; j++){
					for(var z = j+1; z < betting[user_play].one.length; z++){
						for(var x = z+1; x < betting[user_play].one.length; x++){
							for(var c = x+1; c < betting[user_play].one.length; c++){
								for(var v = c+1; v < betting[user_play].one.length; v++){
									for(var b = v+1; b < betting[user_play].one.length; b++){
										for(var n = b+1; n < betting[user_play].one.length; n++){
											tmp[index]    = {'bet':[betting[user_play].one[i], betting[user_play].one[j], betting[user_play].one[z], betting[user_play].one[x], betting[user_play].one[c], betting[user_play].one[v], betting[user_play].one[b], betting[user_play].one[n]], 'check':'success'};
											index++;
										}
									}
								}
							}
						}
					}
				}
			}
			break;
		case 'RXDT-EZE':
			if(!checkDT_repeat(obj, func, 1, 2)){
				break;
			}
			
			for(var i = 0; i < betting[user_play].two.length; i++){
				tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i]], 'check':'success'};
				index++;
			}
			break;
		case 'RXDT-SZS':
			if(!checkDT_repeat(obj, '', 1, 3)){
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o]], 'check':'success'};
					index++;
				}
			}
			break;
		case 'RXDT-SI_Z_SI':
			if(!checkDT_repeat(obj, '', 1, 4)){
				break;
			}
			if($.inArray(betting[user_play].one[0], betting[user_play].two) > -1){
				// 第二组选项全选，清空第一组
				var bet_out        = betting[user_play].one.pop();
				$('#choice_item_' + bet_out + '[group="1"]').removeClass('curr');
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					for(var p = o + 1; p < betting[user_play].two.length; p++){
						tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o], betting[user_play].two[p]], 'check':'success'};
						index++;
					}
				}
			}
			break;
		case 'RXDT-WZW':
			if(!checkDT_repeat(obj, '', 1, 5)){
				break;
			}
			if($.inArray(betting[user_play].one[0], betting[user_play].two) > -1){
				// 第二组选项全选，清空第一组
				var bet_out        = betting[user_play].one.pop();
				$('#choice_item_' + bet_out + '[group="1"]').removeClass('curr');
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					for(var p = o + 1; p < betting[user_play].two.length; p++){
						for(var z = p + 1; z < betting[user_play].two.length; z++){
							tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o], betting[user_play].two[p], betting[user_play].two[z]], 'check':'success'};
							index++;
						}
					}
				}
			}
			break;
		case 'RXDT-LZW':
			if(!checkDT_repeat(obj, '', 1, 6)){
				break;
			}
			if($.inArray(betting[user_play].one[0], betting[user_play].two) > -1){
				// 第二组选项全选，清空第一组
				var bet_out        = betting[user_play].one.pop();
				$('#choice_item_' + bet_out + '[group="1"]').removeClass('curr');
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					for(var p = o + 1; p < betting[user_play].two.length; p++){
						for(var z = p + 1; z < betting[user_play].two.length; z++){
							for(var x = z + 1; x < betting[user_play].two.length; x++){
								tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o], betting[user_play].two[p], betting[user_play].two[z], betting[user_play].two[x]], 'check':'success'};
								index++;
							}
						}
					}
				}
			}
			break;
		case 'RXDT-QZW':
			if(!checkDT_repeat(obj, '', 1, 7)){
				break;
			}
			if($.inArray(betting[user_play].one[0], betting[user_play].two) > -1){
				// 第二组选项全选，清空第一组
				var bet_out        = betting[user_play].one.pop();
				$('#choice_item_' + bet_out + '[group="1"]').removeClass('curr');
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					for(var p = o + 1; p < betting[user_play].two.length; p++){
						for(var z = p + 1; z < betting[user_play].two.length; z++){
							for(var x = z + 1; x < betting[user_play].two.length; x++){
								for(var c = x + 1; c < betting[user_play].two.length; c++){
									tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o], betting[user_play].two[p], betting[user_play].two[z], betting[user_play].two[x], betting[user_play].two[c]], 'check':'success'};
									index++;
								}
							}
						}
					}
				}
			}
			break;
		case 'RXDT-BZW':
			if(!checkDT_repeat(obj, '', 1, 8)){
				break;
			}
			if($.inArray(betting[user_play].one[0], betting[user_play].two) > -1){
				// 第二组选项全选，清空第一组
				var bet_out        = betting[user_play].one.pop();
				$('#choice_item_' + bet_out + '[group="1"]').removeClass('curr');
				break;
			}
			if($(obj).attr('group') == 1 && betting[user_play].one.length > 1){
				var bet_now        = betting[user_play].one.pop();
				var bet_out        = betting[user_play].one.pop();
				betting[user_play].one.push(bet_now);
				$('#choice_item_' + bet_out).removeClass('curr');
			}
			for(var i = 0; i < betting[user_play].two.length; i++){
				for(var o = i + 1; o < betting[user_play].two.length; o++){
					for(var p = o + 1; p < betting[user_play].two.length; p++){
						for(var z = p + 1; z < betting[user_play].two.length; z++){
							for(var x = z + 1; x < betting[user_play].two.length; x++){
								for(var c = x + 1; c < betting[user_play].two.length; c++){
									for(var v = c + 1; v < betting[user_play].two.length; v++){
										tmp[index]    = {'bet':[betting[user_play].one[0], betting[user_play].two[i], betting[user_play].two[o], betting[user_play].two[p], betting[user_play].two[z], betting[user_play].two[x], betting[user_play].two[c], betting[user_play].two[v]], 'check':'success'};
										index++;
									}
								}
							}
						}
					}
				}
			}
			break;
		default:
			break;
	}
	ready_bet.bet_item = tmp;
	bet_jisuan();
}

function check_import_betting(){
	var tmp         = [];
	var import_str  = $('.tag_import_content').val();
	if(!import_str) { return; }
	// 解析提交内容（先将输入内容转换为统一格式）
	var reg         = /;/g;
	import_str      = import_str.replace(reg, ' ');
	reg             = /,/g;
	import_str      = import_str.replace(reg, ' ');
	var outer       = import_str.split('\n');
	var bt          = '';
	var item        = [];
	var checkRepeat = [];
	
	$.each(outer, function (i, v){
		if(!v){ return true; }
		// 半初始化数据
		item       = {
				'bet': [],
				'check': 'success',
				'unit': [],
		};
		bt = v.split(' ');
		// 清除多余数据（主要是空格数据）
		var tmp_index = 0;
		$.each(bt, function (bi, bv){
			bv    = (bv.trim()).replace('\r\n','');
			if(bv == ''){ return true; }
			
			if(bv < 1 || bv > 11 || ($.inArray(bv, item.bet) > -1) || isNaN(bv)){
				// 正常数值检查
				item.check   = 'error';
			}else{
				item.check   = 'success';
			}
			item.bet.push(bv);
			if(tmp_index == 0){
				betting[user_play].one.push(bv);
			}else if(tmp_index == 1){
				betting[user_play].two.push(bv);
			}else if(tmp_index == 2){
				betting[user_play].three.push(bv);
			}
			tmp_index++;
		})
		oddsArr.push(play_follow.base.item.winner_money);
		tmp.push(item);
	})
	ready_bet = {'bet_name': user_play, 'bet_item': tmp, 'bet_unit': 0, 'bet_money_unit': 0, 'bet_zhushu': 0, 'bet_beishu': 0, 'maxwinner': 0, 'period':resData.lotting.period, 'bet_amount':'', 'betting':betting[user_play] };
	// 玩法中每注号码中号码数量必须是nums才符合当前选择玩法
	var nums = 0;
	switch(play_main.main_index + '-' + play_follow.follow_index){
		case 'SM-QS_ZHI_XDS':
			// 三码玩法：前三直选单式
		case 'SM-QS_ZU_XDS':
			// 三码玩法：前三组选单式
			nums = 3;
			break;
		case 'EM-QE_ZHI_XDS':
			// 二码玩法：前二直选单式
		case 'EM-QE_ZU_XDS':
			// 二码玩法：前二组选单式
			nums = 2;
			break;
		case 'RXDS-YZY':
			// 任选单式：一中一
			nums = 1;
			break;
		case 'RXDS-EZE':
			// 任选单式：二中二
			nums = 2;
			break;
		case 'RXDS-SZS':
			// 任选单式：三中三
			nums = 3;
			break;
		case 'RXDS-SI_Z_SI':
			// 任选单式：四中四
			nums = 4;
			break;
		case 'RXDS-WZW':
			// 任选单式：五中五
			nums = 5;
			break;
		case 'RXDS-LZW':
			// 任选单式：六中五
			nums = 6;
			break;
		case 'RXDS-QZW':
			// 任选单式：七中五
			nums = 7;
			break;
		case 'RXDS-BZW':
			// 任选单式：八中五
			nums = 8;
			break;
		default:
			break;
	}
	$.each(ready_bet.bet_item, function (i, v){
		if(v.bet.length != nums){
			ready_bet.bet_item[i].check = 'error';
		}
	})
	bet_jisuan();
}
/**
 * 胆拖玩法中，  第一组与第二种不允许重复选号，如果重复，清掉对面组选中的同号
 * @param minNum【胆拖最多数】
 */
function checkDT_repeat(obj, func, dtNum, allNum){
	var otherBetArr = '';
	var otherGroup  = 1;
	if($(obj).attr('group') == 1){
		otherBetArr = betting[user_play].two;
		otherGroup  = 2;
	}else{
		otherBetArr = betting[user_play].one;
	}
	if($(obj).attr('group') == 1 && betting[user_play].one.length > dtNum){
		// 胆码最多两个，超过两个则把上次选中的值踢出
		var bet_now = betting[user_play].one.pop();
		var bet_out = betting[user_play].one.pop();
		betting[user_play].one.push(bet_now);
		// 更新选中样式
		$('#id_1_' + bet_out).removeClass('curr');  // 胆码超数，剔除上一个
		$('#id_' + otherGroup + '_' + bet_out).removeClass('curr');
	}
	
	// 检查当前选择的投注数值是否已经存在点亮的数据中
	if($.inArray($(obj).attr('ami'), otherBetArr) > -1){
		// 删除重复数据
		otherBetArr.splice(($.inArray($(obj).attr('ami'), otherBetArr)), 1);
		// 改变选中样式
		$('#id_' + otherGroup + '_' + $(obj).attr('ami')).removeClass('curr');
	}
	if($(obj).attr('group') == 1){
		betting[user_play].two = otherBetArr;
	}else{
		betting[user_play].one = otherBetArr;
	}
	if(parseInt(betting[user_play].one.length + betting[user_play].two.length) < allNum){
		// 总数allNum起
		return false;
	}
	if(betting[user_play].one.length < 1){
		// 胆拖必须
		return false;
	}
	return true;
}

/**
 * 根据预投注内容计算有效投注数
 */
var valid_betnum = 0;
var js_bet_item  = { 'one':[], 'two':[], 'three':[]};
function bet_jisuan(){
	// 有效的投注数
	var valid_betnum = 0;
	if($.isEmptyObject(ready_bet) || $.isEmptyObject(ready_bet.bet_item)){
		$('.tag_bet_count').html(valid_betnum);
		return;
	}
	var beishu     = $('#id_user_bet_beishu').val();
	
	$.each(ready_bet.bet_item, function (i, v){
		if(v.check == 'success') valid_betnum++;
		// 倍数
		ready_bet.bet_item[i].multiple = beishu;
		// 金额
		ready_bet.bet_item[i].eo_money = default_bet_money;
	})
	
	$('.tag_bet_count').html(valid_betnum);
	// 获取金额单位
	var money_unit_dom = $('.tag_money_unit[class="tag_money_unit curr"]');
	var money_unit     = money_unit_dom.attr('amv');
	var money_unit_cn  = money_unit_dom.attr('amt');
	var amount         = 0; 
	// 开始计算金额:  默认每注金额 * 金额单位 * 投注组数 * 投注倍数
	amount = parseFloat(default_bet_money * money_unit * beishu * valid_betnum).toFixed(2);
	
	ready_bet.lott_id        = resData.lotteryInfo.id;
	ready_bet.bet_money_unit = money_unit;
	ready_bet.bet_zhushu     = valid_betnum;
	ready_bet.bet_beishu     = beishu;
	ready_bet.bet_amount     = parseFloat(amount).toFixed(2);
	ready_bet.maxwinner      = (1 * oddsArr[0] * parseFloat(money_unit)).toFixed(2);
	ready_bet.betting        = betting[user_play];
	ready_bet.period         = resData.lotting.id;
	$('#id_choice_zhushu').html(valid_betnum);
	$('#id_choice_amount').html(amount);
}

// 如果用户选择号码产生一注以上有效号码，则展示投注底部投注信息说明，并点亮购物车选项
function checkBetsNums(){
	var all_bets_nums = ready_bet.bet_zhushu;
	// 没有有效的投注
	if(all_bets_nums <= 0) return;
	$('#id_sscFooter').removeClass('active');
	if(all_bets_nums <= 0) return;
	// 展示用户投注设置选项（倍数与金额单位）
	$('#id_user_bets_set').show();
	$('#id_sscFooter').addClass('active');
	// 展示用户所选择的投注项
	var bettingData = ready_bet.betting;
	var betting_str = bettingData.one.join(' ') + ', ' + bettingData.two.join(' ') + ', ' + bettingData.three.join(' ');
	$('#id_betting_str').html(betting_str);
}

/**
 * 用户选择的投注项增加到购物车中
 */
function addCart(){
//	console.log(ready_bet);
	if(ready_bet.bet_zhushu <= 0) return;
	// 清除选项中无用的投注数据（用户手动输入的时候，如果输入了奇葩选项）
	var checkBet = ready_bet.bet_item;
	var tmp      = [];
	$.each(checkBet, function (i, v){
		if(v.check == 'success'){
			// 移除无用数据(直接循环删除， 会有问题，移除之后数据源的下标立刻就变了)
			tmp.push(v);
		}
	});
	ready_bet.bet_item = tmp;
	// 记录当前加入购物车的序号，用作对应删除购物车
	cart_index++;
	// 计算用户投注的内容，以后不用重复计算
	var bettingData       = ready_bet.betting;
	var bet_string        = bettingData.one.join(' ') + ', ' + bettingData.two.join(' ') + ', ' + bettingData.three.join(' ');
	ready_bet.bet_string  = bet_string;
	ready_bet.cart_index  = cart_index;
	// 基础投注金额
	ready_bet.eo_money    = default_bet_money;
	betCart.push(ready_bet);
	// 将添加到购物车的数据，追加到购物车列表
	var play_str  = '';
	var play_type = '';
//	$('#id_cart_betting_list').html(function (){
//		play_type = v.bet_name.split('-');
//		play_str  = resData.playItem.mainItem[play_type[0]].play_name + ' ' + resData.playItem.mainItem[play_type[0]].play[play_type[1]].name;
//		var str = '<li amv="' + cart_index + '">';
//		str    += '		<em>' + bet_string + '</em> ';
//		str    += '		<span>' + play_str + ready_bet.bet_zhushu + '注×' + (default_bet_money * ready_bet.bet_money_unit) + '元×' + ready_bet.bet_beishu + '倍  = ' + ready_bet.bet_amount + '元</span>';
//		str    += '		<a class="tag_drop_bet" amv="' + cart_index + '"></a>';
//		str    += '</li>';
//		$(this).append(str);
//	});
	balanceCart();
	// 初始化投注预览
	reBetInit();
	// 重构购物车
	balanceCart();
}

/**
 * 重选玩法，初始化投注预览
 */
function reBetInit(){
	ready_bet             = {};
	betting[user_play]    = {
		'one'   : new Array(),
		'two'   : new Array(),
		'three' : new Array(),
	};
	// 初始化页面选择项
	fillPlayBody();
	// 初始化底部投注预览信息
	$('#id_sscFooter').removeClass('active');
	$('#id_choice_zhushu').html('0');
	$('#id_choice_amount').html('0.00');
	$('#id_betting_str').html('');
	$('#id_user_bet_beishu').val('1');
	$('.tag_money_unit').removeClass('curr');
	$('.tag_money_unit:eq(0)').addClass('curr');
	$('#id_user_bets_set').hide();
	$('#id_cart_nums').html(betCart.length);
	$('#id_cart_nums').show();
}

/**
 * 删除购物车
 */
function dropCart(index){
	var drop_id = 0;
	$.each(betCart, function (i, v){
		drop_id = i;
		// 获取到当前购物车中要删除选项的下标
		if(v.cart_index == index) return false;
	})
	// 删除投注项
	betCart.splice(drop_id, 1);
	balanceCart();
	$('#id_cart_nums').html(betCart.length);
	if(betCart.length == 0){
		$('#id_cart_nums').hide();
	}
	// 重构购物车
	balanceCart();
}

/**
 * 清空购物车
 */
function clearCart(){
	$('#id_cart_betting_list').html('');
	betCart = [];
	// 重新结算数据
	balanceCart();
	// 页面样式初始化
	$('#id_cart_zhus').html('0');
	$('#id_cart_amounts').html('0.00');
	$('#id_cart_nums').html('0');
	$('#id_cart_nums').hide();
}

///**
// * 结算购物车数据预览
// */
//function balanceCart(){
//	var zhus    = 0;
//	var amounts = 0;
//	$.each(betCart, function (i, v){
//		amounts += parseFloat(v.bet_amount);
//		zhus    += v.bet_zhushu;
//	})
//	$('#id_cart_zhus').html(zhus);
//	$('#id_cart_amounts').html(amounts.toFixed(2));
//}

/**
 * 重构购物车
 */
function reBuildCart(){
	$('#id_cart_betting_list').html(function (){
		$(this).html('');
		var str       = '';
		var play_str  = '';
		var play_type = '';
		$.each(betCart, function (i, v){
			play_type = v.bet_name.split('-');
			play_str  = resData.playItem.mainItem[play_type[0]].play_name + ' ' + resData.playItem.mainItem[play_type[0]].play[play_type[1]].name;
			cart_index = i;
			str     = '<li amv="' + v.cart_index + '">';
			str    += '		<em>' + v.bet_string + '</em> ';
			str    += '		<span>' + play_str + v.bet_zhushu + '注×' + (default_bet_money * v.bet_money_unit) + '元×' + v.bet_beishu + '倍  = ' + v.bet_amount + '元</span>';
			str    += '		<a class="tag_drop_bet" amv="' + v.cart_index + '"></a>';
			str    += '</li>';
			$('#id_cart_betting_list').append(str);
		});
	});
}

/**
 * 结算购物车
 */
function balanceCart(){
	// 空购物车
	if($.isEmptyObject(betCart)) return;
	// 检查是否有追号
	var is_chase = $('#id_chase').prop('checked');
	var chase_beishu = $('#id_chase_beishu').val();
	var chase_qishu  = $('#id_chase_qishu').val();
	var tmp_sum      = 0;
	// 统计数据
	var zhus     = 0;
	var amounts  = 0;
	$.each(betCart, function (i,v){
		if(is_chase == true){
			// 追号， 将所有投注信息变更为基础1倍。（因为追号会重设投注倍数）
			betCart[i].bet_beishu = 1;
		}
		tmp_sum               = parseFloat(v.bet_zhushu * v.eo_money * v.bet_money_unit * betCart[i].bet_beishu);
		betCart[i].bet_amount = parseFloat(tmp_sum * chase_beishu * chase_qishu).toFixed(2);
		amounts += tmp_sum * chase_beishu * chase_qishu;
		zhus    += parseInt(v.bet_zhushu);
	});
	// 重构购物车
	reBuildCart();
	$('#id_cart_zhus').html(zhus);
	$('#id_cart_amounts').html(amounts);
}

//安全提交
var securityPost       = true;
/**
 * 投注
 */
function doBet(){
	if(securityPost == false){
		showMsg('温馨提示', '请等待提交结果');
		return;
	}
	if(betCart.length <= 0) {
		showMsg('温馨提示', '请选择有效的投注号');
		return;
	}
	var param = {'lott_id':resData.lotteryInfo.id, 'cart':betCart};
	// 检查是否有追号设置
	if($('#id_chase').prop('checked') == true){
		// 设置追号的倍数与期数
		param.beishu = $('#id_chase_beishu').val();
		param.qishu  = $('#id_chase_qishu').val();
		param.chase  = true;
	}
	// 安全提交限制
	securityPost = false;
	$.ajax({  
		type:'post',    
	    url: doBetUrl,  
	    data:'data=' + JSON.stringify(param),  
	    cache:false,  
	    dataType:'json',
	    success:function(res){  
	    	if(res.status == 'success'){
	    		showMsg('温馨提示', '<span style="color:red">投注成功</span>，您可以在我的账户查看注单详情', 'success');
	    		clearCart();
	    		// 初始化投注预览
	    		reBetInit();
			}else{
				showMsg('温馨提示', '投注失败，请重试', '');
			}
	    	// 释放提交
	    	securityPost = true;
	    },
	    error:function (XMLHttpRequest, textStatus, errorThrown){
	    	// 释放提交
	    	securityPost = true;
	    }
	})
}

///**
// * 随机产生投注信息
// */
//function randBet(){
////	betting[user_play]
//	betting[user_play]    = {
//		'one'   : [],
//		'two'   : [],
//		'three' : [],
//	};
//	var first   = 0;
//	var second  = 0;
//	var third   = 0;
//	var repeat  = false;
//	// 根据当前选择的不同玩法来制定随机规则
//	switch(user_play){
//		case 'SM-QS_ZHI_XFS':
//		// 三码玩法：前三直选复式
//		case 'SM-QS_ZHI_XDS':
//			// 三码玩法：前三直选单式
//		case 'SM-QS_ZU_XFS':
//			// 三码玩法：前三组选复式
//		case 'SM-QS_ZU_XDS':
//			// 三码玩法：前三组选单式
//			first  = 1;
//			second = 1;
//			third  = 1;
//			break;
//		case 'SM-QS_ZU_XDT':
//			// 三码玩法：组选胆拖
//			first  = 1;
//			second = 2;
//			break;
//		
//		case 'EM-QE_ZHI_XFS':
//			// 二码玩法：前二直选复式
//		case 'EM-QE_ZHI_XDS':
//			// 二码玩法：前二直选单式
//		case 'EM-QE_ZU_XFS':
//			// 二码玩法：前二组选复式
//		case 'EM-QE_ZU_XDS':
//			// 二码玩法：前二组选单式
//			first  = 2;
//			break;
//		case 'EM-QE_ZU_XDT':
//			// 二码玩法：前二组选胆拖【胆码最多两个，胆拖可多个，并且胆码胆拖整体不重复数】
//			first  = 1;
//			second = 1;
//			break;
//		
//		case 'BDW-QSYMBDW':
//			// 不定位：前三一码不定位
//			first  = 1;
//			break;
//			
//		case 'DWD-FS':
//			// 定位胆：复式
//			first  = 1;
//			second = 1;
//			third  = 1;
//			repeat = true;
//			break;
//			
//		case 'QWX-DDS':
//			// 趣味型：定单双
//			first  = 1;
//			break;
//		case 'QWX-CZW':
//			// 趣味型：猜中位
//			first  = 1;
//			break;
//
//		case 'RXDS-YZY':
//			// 任选单式：一中一
//		case 'RXFS-YZY':
//			// 任选复式：一中一
//			first  = 1;
//			break;
//		case 'RXDS-EZE':
//			// 任选单式：二中二
//		case 'RXFS-EZE':
//			// 任选复式：二中二
//			first  = 2;
//			break;
//		case 'RXDS-SZS':
//			// 任选单式：三中三
//		case 'RXFS-SZS':
//			// 任选复式：三中三   
//			first  = 3;
//			break;
//		case 'RXDS-SI_Z_SI':
//			// 任选单式：四中四
//		case 'RXFS-SI_Z_SI':
//			// 任选复式：四中四
//			first  = 4;
//			break;
//		case 'RXDS-WZW':
//			// 任选单式：五中五
//		case 'RXFS-WZW':
//			// 任选复式：五中五
//			first  = 5;
//			break;
//		case 'RXDS-LZW':
//			// 任选单式：六中五
//		case 'RXFS-LZW':
//			first  = 6;
//			break;
//		case 'RXDS-QZW':
//			// 任选单式：七中五
//		case 'RXFS-QZW':
//			first  = 7;
//			break;
//		case 'RXDS-BZW':
//			// 任选单式：八中五
//		case 'RXFS-BZW':
//			first  = 8;
//			break;
//		case 'RXDT-EZE':
//			first  = 1;
//			second = 1;
//			break;
//		case 'RXDT-SZS':
//			first  = 1;
//			second = 2;
//			break;
//		case 'RXDT-SI_Z_SI':
//			first  = 1;
//			second = 3;
//			break;
//		case 'RXDT-WZW':
//			first  = 1;
//			second = 4;
//			break;
//		case 'RXDT-LZW':
//			first  = 1;
//			second = 5;
//			break;
//		case 'RXDT-QZW':
//			first  = 1;
//			second = 6;
//			break;
//		case 'RXDT-BZW':
//			first  = 1;
//			second = 7;
//			break;
//		default:
//			break;
//	}
//}

/**
 * 投注预览
 */
function betViewMsg(){
	if($.isEmptyObject(betCart)) {
		showMsg('', '未选择投注内容');
		return;
	}
	var tmp_mp = '';
	var tmp_fp = '';
	var str    = resData.lotteryInfo.title + '：' + resData.lotting.period + '期<br/>';
	str    += '投注金额：' + $('#id_cart_amounts').html();
	str    += '投注内容：<br/>';
	$.each(betCart, function (i, v){
		tmp_mp = v.bet_name.split('-');
		str += '[' + resData.playItem.mainItem[tmp_mp[0]].play_name + ',' + 
				resData.playItem.mainItem[tmp_mp[0]].play[tmp_mp[1]].name +
				v.bet_string + '<br/>';
	})
	showMsg('投注确认', str, 'bet');
}

//倒计时结束提示弹框
function showMsg(title='温馨提示', msg, type){
	if(!title){return}
	switch(type){
		case 'bet':
			var bet_status = false;
			layer.open({
				title: title,
				content: msg,
				className: 'layui-m-tag-msg',
				btn: ['投注','取消'],
				yes: function (index){
					doBet();
		        	layer.close(index);
				}
			});
			break;
		case 'success':
			layer.open({
	            title: '温馨提示',
	            content: '<span style="color:red">投注成功</span>，您可以在我的账户查看注单详情',
	            className: 'layui-m-tag-msg',
	            btn: ['继续投注', '查看注单'],
	            yes: function (index){
					// 继续投注
	            	layer.close(index);
	            },
	            no: function (index){
	            	// 查看注单
	            	window.location = memberBet;
	            }
	        });
			break;
		default:
			layer.open({
				title: title,
				content: msg,
				className: 'layui-m-tag-msg',
				btn: ['确定'],
				yes: function (index){
					layer.close(index);
				}
			});
			break;
	}
}


















